import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';
import 'package:search_people/bean/search/hot_people.dart';
import 'package:search_people/page/home/subs/person_detail/models/person_dynamic_model.dart';
import 'package:search_people/utils/component/component.dart';

import '../../../entrance/route/routes.dart';

// ignore_for_file: non_constant_identifier_names
enum HomeMenuType {
  searchSuper,
  searchArea,
  searchShcool,
  searchBirthPlace,
  searchBirthDay,
  searchJob,
  function,
  all;

  static HomeMenuType init(int num) {
    switch (num) {
      case 1:
        return HomeMenuType.searchArea;
      case 2:
        return HomeMenuType.searchShcool;
      case 3:
        return HomeMenuType.searchBirthPlace;
      case 4:
        return HomeMenuType.searchBirthDay;
      case 5:
        return HomeMenuType.searchJob;
      case 6:
        return HomeMenuType.function;
      case 7:
        return HomeMenuType.all;
      default:
        return HomeMenuType.searchSuper;
    }
  }

  int get val {
    switch (this) {
      case HomeMenuType.searchSuper:
        return 0;
      case HomeMenuType.searchArea:
        return 1;
      case HomeMenuType.searchShcool:
        return 2;
      case HomeMenuType.searchBirthPlace:
        return 3;
      case HomeMenuType.searchBirthDay:
        return 4;
      case HomeMenuType.searchJob:
        return 5;
      case HomeMenuType.function:
        return 6;
      case HomeMenuType.all:
        return 7;
      default:
        return 0;
    }
  }

  String get title {
    switch (this) {
      case HomeMenuType.searchSuper:
        return '高级搜索';
      case HomeMenuType.searchArea:
        return '按区域查';
      case HomeMenuType.searchShcool:
        return '按学校查';
      case HomeMenuType.searchBirthPlace:
        return '按籍贯查';
      case HomeMenuType.searchBirthDay:
        return '按出生年代';
      case HomeMenuType.searchJob:
        return '按其他类型';
      case HomeMenuType.function:
        return '功能按钮';
      case HomeMenuType.all:
        return '全部';
      default:
        return '高级搜索';
    }
  }

  String get icon {
    switch (this) {
      case HomeMenuType.searchSuper:
        return 'akp.png';
      case HomeMenuType.searchArea:
        return 'aki.png';
      case HomeMenuType.searchShcool:
        return 'akt.png';
      case HomeMenuType.searchBirthPlace:
        return 'akh.png';
      case HomeMenuType.searchBirthDay:
        return 'al1.png';
      case HomeMenuType.searchJob:
        return 'akw.png';
      case HomeMenuType.function:
        return 'akv.png';
      case HomeMenuType.all:
        return 'afj.png';
      default:
        return 'akp.png';
    }
  }

  static List<HomeMenuType> get searchItems {
    return [
      HomeMenuType.searchSuper,
      HomeMenuType.searchArea,
      HomeMenuType.searchShcool,
      HomeMenuType.searchBirthPlace,
      HomeMenuType.searchBirthDay,
      HomeMenuType.searchJob,
    ];
  }
}

class HomeState {
  late TabController tabCtrl;
  late List<MenuItem> menuItems;
  late List<String> tabTitles;
  List<HotPeople> hots = [];
  late BrnGuide intro;
  List<PersonDynamicModel> dynamics = [];

  List<BrnSelectCityModel>? cityList;
  List<BrnSelectCityModel>? schoolList;
  List<BrnSelectCityModel>? jobList;

  RefreshController? rc;

  late int pageIndex;

  late GlobalKey hot_peopleKey;

  HomeState() {
    ///Initialize variables
    hot_peopleKey = GlobalKey();
    pageIndex = 0;
    intro = BrnGuide(
      stepCount: 2,
      introMode: GuideMode.force,

      /// use defaultTheme, or you can implement widgetBuilder function yourself
      widgetBuilder: StepWidgetBuilder.useDefaultTheme(
        tipInfo: [
          BrnTipInfoBean("搜索框", "这里搜索人名、地区等", ""),
          BrnTipInfoBean("功能区", "高级搜索等功能按钮", ""),
        ],
      ),
    );

    tabTitles = [
      '热门动态',
      '人事快讯',
      '资讯板块',
    ];
  }
}
